package ccm.component.menu;

public enum ScnsType
{
    SCNS_TYPE_INT8,
    SCNS_TYPE_UINT8,
    SCNS_TYPE_INT16,
    SCNS_TYPE_UINT16,
    SCNS_TYPE_INT32,
    SCNS_TYPE_FLOAT,
    SCNS_TYPE_DOUBLE,
    SCNS_TYPE_FUNCTION,
    SCNS_TYPE_ENUM,
    SCNS_TYPE_BOOLEAN,
    SCNS_TYPE_UINT32,
    SCNS_TYPE_INT64,
    SCNS_TYPE_UINT64,
    SCNS_TYPE_MAX;

    public static ScnsType valueOf(int value)
    {
        for(ScnsType type: ScnsType.values()){if(type.ordinal()==value){return type;}}
        throw new IllegalArgumentException();
    }

    public int sizeOf()
    {
        return ScnsType.sizeOf(this);
    }

    public static int sizeOf(ScnsType type)
    {
        switch(type)
        {

            case SCNS_TYPE_INT8:
            case SCNS_TYPE_UINT8:
            case SCNS_TYPE_BOOLEAN:
                return 1;
            case SCNS_TYPE_INT16:
            case SCNS_TYPE_UINT16:
                return 2;
            case SCNS_TYPE_INT32:
            case SCNS_TYPE_UINT32:
            case SCNS_TYPE_FLOAT:
                return 4;
            case SCNS_TYPE_DOUBLE:
            case SCNS_TYPE_INT64:
            case SCNS_TYPE_UINT64:
                return 8;
        }
        throw new IllegalArgumentException();
    }

    @Override
    public String toString()
    {
        return super.toString().substring(10);
    }
}